<template>
  <el-tree-select v-model="name" lazy :load="load" :props="treeProps" :data="data" />
</template>

<script setup lang="ts">
import { computed, onMounted } from "vue";
const { proxy } = getCurrentInstance();
let props = defineProps(["modelValue", "val", "multiple"]);
const emit = defineEmits(["update:modelValue", "fatherMethods"]);
let data = ref([]);

onMounted(() => {
  getData();
});
const name = computed({
  get() {
    return props.modelValue;
  },
  set(value: Number) {
    emit("update:modelValue", value);
  },
});
const treeProps = ref({
  label: "areaName",
  value: "areaCode",
});

let getData = async () => {
  data.value = await getInfo();
};

let getInfo = async (areaId) => {
  let resp = await proxy.$apis.areaDist({ areaId });
  return resp;
};

let load = async (node, resolve) => {
  let arr = await getInfo(node.data.areaId);
  resolve(arr);
};
</script>

<style lang="scss" scoped>
</style>
